/**
 * 将对象变为字符串
 * @param {请求链接} path
 * @param {请求参数} data
 */
export const queryString = (path: string, data: {}) => {
  const arr: string[] = [];
  for (const key in data) {
    if (Object.prototype.hasOwnProperty.call(data, key)) {
      arr.push(`${key}=${data[key]}`);
    }
  }
  return `${path}?${arr.join('&')}`;
};

/**
 * 判断数据类型
 * @param {any} value
 * @param {TypeInfo} type
 */
type TypeInfo = 'String'|'Number'|'Boolean'|'Undefined'|'Null'|'Function'|'Array'|'Object';
export const isTypeOf = (value: any, type: TypeInfo) => {
  return Object.prototype.toString.call(value) === `[object ${type}]`;
};
